<?php

class group_model extends Model
{	
	public $group_id;
	public $group_no;
	public $value;
	public $no_of_month ;
	public $no_of_members;
	public $installment_amt;
	public $auction_date;
	public $auction_time;
	public $max_bid;
	public $min_bid;
	public $due_fine;
	public $auction_type;
	
	public function __construct() 
	{
		parent::Model();
	}

	public function getAll()
	{
		$query = $this->db->get('group');
		return $query->result();
	}
	
	public function getById($group_id) 
	{
		$query = $this->db->get_where('group', array('group_id' => $group_id));
		return $query->row();
	}

	private function insert($post) 
	{
		
		return $this->db->insert('group', $this);
	}
	
	private function update($post) 
	{
		$this->db->set('group_no', $this->group_no);
		$this->db->set('value', $this->value);
		$this->db->set('no_of_month', $this->no_of_month);
		$this->db->set('no_of_members', $this->no_of_members);
		$this->db->set('installment_amt', $this->installment_amt);
		$this->db->set('auction_date', $this->auction_date);
		$this->db->set('auction_time', $this->auction_time);
		$this->db->set('max_bid', $this->max_bid);
		$this->db->set('min_bid', $this->min_bid);
		$this->db->set('due_fine', $this->due_fine);
		$this->db->set('auction_type', $this->auction_type);
		$this->db->where('group_id', $this->group_id);
		return $this->db->update('group');
	}

	public function delete($post) 
	{
		$this->db->where('group_id', $this->group_id);
		return $this->db->delete('group');
	}
	
	public function save($post) 
	{
		if (isset($this->group_id)) {	
			return $this->update($post);
		} else {
			return $this->insert($post);
		}
	}
}